import requests
import json
import urllib.parse  

Authorization = 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJhdXRob3JpdGllcyI6IiIsInVzZXJJZCI6InJvb3QiLCJ0ZW5hbmN5SWRzIjoiZGVmYXVsdCIsInN1YiI6Ijc3ZWQzMzA4LWZiMzMtNDM3Yy1iZTM2LWQ4MGUyNmE2YjEwYiIsImV4cCI6MTcwNDIwMDgzOX0.xgmagS9gLZzCHCTMYRVc_-mDLcc31JA3h7jaO-it8FpV2wl_BlbWQvrx2pp2-iad_9uQW44T7uwyBGZQSf94HA'

headers = {
    'Accept':'application/json, text/plain, */*',
    'Accept-Encoding':'gzip, deflate',
    'Accept-Language':'zh-CN,zh;q:0.9,en;q:0.8',
    'Authorization':'Bearer eyJhbGciOiJIUzUxMiJ9.eyJhdXRob3JpdGllcyI6IiIsInVzZXJJZCI6InJvb3QiLCJ0ZW5hbmN5SWRzIjoiZGVmYXVsdCIsInN1YiI6Ijc3ZWQzMzA4LWZiMzMtNDM3Yy1iZTM2LWQ4MGUyNmE2YjEwYiIsImV4cCI6MTcwNDIwMDgzOX0.xgmagS9gLZzCHCTMYRVc_-mDLcc31JA3h7jaO-it8FpV2wl_BlbWQvrx2pp2-iad_9uQW44T7uwyBGZQSf94HA',
    'Cache-Control':'no-cache',
    'Origin':'http://localhost:8080',
    'Pragma':'no-cache',
    'Referer':'http://localhost:8080/',
    'Content-Type': 'application/json',
}

def mainScreen(name, redirect, dataIndex):
    urlValue = 'http://192.168.15.155:8090/teenager/sys/authoritys'
    print(name)
    params =  {
        
        "authorityName": "",
        "dataIndex": 0,
        "description": "",
        "enabled": 0,
        "iconCls": "",
        "menuUrl": "",
        "parentId": "",
        "permission": "",
        "tenancyId": "",
        "type": 0
    }
    # params = {'enabled':""}
    # {'authorityName':name,'menuUrl':redirect,'permission':'','dataIndex':dataIndex,'type':1,'enabled':1,}
    # params = urllib.parse.urlencode(params)  
    res = requests.post(urlValue,headers=headers, data=params)
    print(res.text)
   
    
    
    
def mainListScreen():
    # http://192.168.15.155:8090/teenager/sys/authoritys
    urlValue = 'http://192.168.15.155:8090/teenager/sys/authoritys'
    params = {
        'authorityName':'轮播管理-新增',
        'menuUrl':'/carouselBanner/carouselBanner-itemAdd',
        'permission':'',
        'dataIndex':11,
        'type':1,
        'enabled':1,
        'parentId':'6077a3afb2ca494db8b747b1db960c89'}
    res = requests.post(urlValue,params=params)
    print(res.text)
    
def listScreen():
    urlValue = 'http://192.168.15.155:8090/teenager/sys/authoritys'
    res = requests.get(urlValue,headers={'Authorization': Authorization})
    # print(res.json())
    resJson = res.json()
    for item in resJson['rows']:
        # authorityId
        print(item['authorityName'])
    
# listScreen()


list = [{
		'path': '/carouselBanner',
		'component': 'Layout',
		'name': '轮播管理',
		'redirect': '/carouselBanner/index',
		'meta': {
			'title': '轮播管理',
			'icon': 'public-carouselBanner'
		},
		'children': [{
				'path': 'index',
				'name': 'carouselBanner',
				'meta': {
					'title': '轮播管理',
					'icon': 'public-carouselBanner'
				},
			},
			{
				'path': 'itemAdd',
				'name': 'carouselBanner-itemAdd',
				'meta': {
					'title': '轮播管理-新增',
					'activeMenu': '/carouselBanner/index'
				},
				'hidden': True,
			},
			{
				'path': 'itemEdit',
				'name': 'carouselBanner-itemEdit',
				'meta': {
					'title': '轮播管理-修改',
					'activeMenu': '/carouselBanner/index'
				},
				'hidden': True,
			},
		],
		'hidden': False,
	}];
# print(list['redirect'])
for i in range(0, len(list)):
    item = list[i];
    name = item['name']
    redirect = item['redirect']
    dataIndex = i * 10
    mainScreen(name, redirect, dataIndex)
